using UnityEngine;
using UnityEngine.UI;

public class EnemyHealthBar : MonoBehaviour
{
    [SerializeField] private EnemyHealth enemyHealth;
    [SerializeField] private Slider healthSlider;
    
    private void Awake()
    {
        healthSlider.maxValue = enemyHealth.maxHealth;
        UpdateHealthBar();
    }
    
    private void UpdateHealthBar()
    {
        healthSlider.value = enemyHealth.currentHealth;
    }
    
    // 可以在EnemyHealth中添加事件，或在此脚本中定期更新血条
    private void Update()
    {
        UpdateHealthBar();
    }
}